﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

using DAL;
using Model;

namespace BLL
{
    public class ActivityBLL
    {
        public ActivityBLL()
        { }

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            //TODO: 
            return ActivityDAL.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            //TODO: ADD  return EnterpriseUserDAL.Exists(ID);
            return true;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Activity model)
        {
            //TODO: ADD  return EnterpriseUserDAL.Add(model);
            return ActivityDAL.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Activity model)
        {
            //TODO: ADD return  EnterpriseUserDAL.Update(model);
            return ActivityDAL.Update(model);
        }

        public int UpdateActivityRptSettings(string actid, int RPTvalue)
        {
            return ActivityDAL.UpdateActivityRptSettings(actid, RPTvalue);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int activity_id)
        {
            ActivityDAL.Delete(activity_id);
        }

        public DataSet GetEUsrInfoByActivityId(int activity_id)
        {
            return ActivityDAL.GetEnterpriseInfoByactivityId(activity_id);
        }

        public int UpdateActivityStatus(string actid, string ponsitionid, string enterpriseid, bool isDisable)
        {
            return ActivityDAL.UpdateActivityStatus(actid,ponsitionid,enterpriseid,isDisable);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Activity GetModel(int activityid)
        {
            // TODO: ADD return EnterpriseUserDAL.GetModel(ID);
            return ActivityDAL.GetModel(activityid);
        }

        public DataSet GetActivityByPositionId(string positionId)
        {
            return ActivityDAL.GetActivityByPositionId(positionId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetActivityAll(string strWhere)
        {
            return ActivityDAL.GetList(strWhere);
        }

        public DataSet GetActivityByUser(string eUser)
        {
            AdminUserBLL adminBll = new AdminUserBLL();
            DataSet dsEuser = adminBll.GetEnterpriseUserByName(eUser);
            string user_id = dsEuser.Tables[0].Rows[0]["users_id"].ToString();
            adminBll = null;

            DataSet ds = ActivityDAL.GetList(user_id);
            return ds;
        }

        public DataSet GetActivityByUserAndDimen(string eUser)
        {
            AdminUserBLL adminBll = new AdminUserBLL();
            DataSet dsEuser = adminBll.GetEnterpriseUserByName(eUser);
            string user_id = dsEuser.Tables[0].Rows[0]["users_id"].ToString();
            adminBll = null;

            DataSet ds = ActivityDAL.GetListAndDimen(user_id);
            return ds;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Activity> GetModelList(string strWhere)
        {
            DataSet ds = ActivityDAL.GetList(strWhere);
            List<Activity> modelList = new List<Activity>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                Activity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Activity();

                    //TODO: ADD MODEL
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList(string eUserID)
        {
            return ActivityDAL.GetList(eUserID);
        }

        public  int GetPositionId(int activityId)
        {
            return ActivityDAL.GetPositionId(activityId);
        }

        public string GetActivityNM(int activity_id)
        {
            return ActivityDAL.GetActivityNM(activity_id);
        }
    }
}
